package io_exercise;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

public class PWDemo1 {
    public static void main(String[] args) throws FileNotFoundException {
        FileOutputStream fos1=new FileOutputStream("pw1.txt");//文件流
        OutputStreamWriter osw1=new OutputStreamWriter(fos1, StandardCharsets.UTF_8);//转换字符流
        BufferedWriter bw1=new BufferedWriter(osw1);//缓冲字符流
        PrintWriter pw1=new PrintWriter(bw1,true);
        Scanner scan=new Scanner(System.in);
        System.out.println("请输入内容,单独输入exit时退出");
        while (true){
            String line1=scan.nextLine();
            if("exit".equals(line1)){
                System.out.println("写出完毕,退出");
                break;
            }
            pw1.println(line1);
        }
        pw1.close();


    }
}
